<template>
    <section>
      <div class="register">
        <router-link :to="{name:'mineed'}"><span class="glyphicon glyphicon-menu-left pull-left"></span></router-link>
        <span class="register-span">账户信息</span>
      </div>
      <div class="blank"></div>
      <!--修改头像-->
      <div class="centre">
        <input type="file">
        <p>头像</p>
        <img :src="'https://elm.cangdu.org/img/'+ personMsg.avatar" class="img-circle" alt="">
        <span class="glyphicon glyphicon-menu-right centre-span"></span>
      </div>
      <!--修改用户名-->
      <div class="username">
        <router-link :to="{name:'alter'}">
          <p class="username-span1">用户名</p>
          <span class="username-span2" >{{personMsg.username}}</span>
          <span class="glyphicon glyphicon-menu-right username-span3"></span>
        </router-link>
      </div>
      <!--修改地址-->
      <div class="username">
        <router-link :to="{name:'site'}">
          <p class="username-span1">收货地址</p>
          <span class="glyphicon glyphicon-menu-right  pull-right username-span3"></span>
        </router-link>
      </div>
      <!--账号绑定-->
      <div class="id">
        <p>账号绑定</p>
      </div>
      <div class="username" @click="phone">
        <span class="glyphicon glyphicon-phone span"></span>
        <p class="username-cellphone">手机</p>
        <span class="glyphicon glyphicon-menu-right  pull-right username-span3"></span>
      </div>
      <mt-popup v-model="popupVisible" position="center" :closeOnClickModal='false' :modal="false" class="animated bounceIn center-popup">
        <div >
          <i class="iconfont">&#xe604;</i>
          <p class="p">请在手机APP中设置</p>
          <button class="btn btn-success" @click="popup">确认</button>
        </div>
      </mt-popup>
      <div class="id">
        <p>安全设置</p>
      </div>
      <div class="username" @click="password">
        <router-link :to="{name:'reset'}">
          <p class="username-span1">登录密码</p>
          <span class="username-span2">修改</span>
          <span class="glyphicon glyphicon-menu-right  pull-right username-span3"></span>
        </router-link>
      </div>
      <div class="end">
        <button @click="toAlert" class="btn btn-danger">退出登录</button>
      </div>
      <mt-popup v-model="isShowDialogs" :closeOnClickModal='false' :modal="false" class="animated bounceIn center-popup">
        <div >
          <i class="iconfont">&#xe604;</i>
          <p class="p">是否退出登录</p>
          <div class="paymentdetail_div2">
            <button class="btn button" @click="isShowRefruct">再等等</button>
            <button class="btn btn-danger button1" @click="isShowAgree">退出登录</button>
          </div>
        </div>
      </mt-popup>
      <router-view></router-view>
    </section>
</template>

<script>
  import Vue from 'vue'
  //引入动画组件
  import animate from '../../../../node_modules/animate.css/animate.css'
  //引入mintUI组件
  import { Popup } from 'mint-ui';
  Vue.component(Popup.name, Popup);
    export default {
        name: "Account",
      data(){
          return {
            popupVisible:false,
            isShowDialogs: false,
            personMsg:JSON.parse(localStorage.getItem('personObj')),//获取用户信息
          }
      },
      methods:{
        toAlert(){
          this.isShowDialogs = true
        },
        phone(){
          // 弹出手机提示框
          this.popupVisible = true
        },
        password(){},
        popup(){
          // 不显示弹出框
          this.popupVisible = false
        },
        //退出登录
        isShowRefruct() {
          this.isShowDialogs = false;
          // this.$router.push({path:'/account'})
        },
        //退出登录
        isShowAgree() {
          Vue.axios.get('https://elm.cangdu.org/v2/signout').then(res=>{
            console.log(res.data);
            if (res.data.message == '退出成功') {
              localStorage.removeItem('personObj');
              this.isShowDialogs = false;
              this.$router.push({name:'mineed'});
            }
          })

        }
      },
      created(){
          console.log(this.personMsg)
      },

    }
</script>

<style scoped>
  .paymentdetail_div2 {
    width: 40%;
    margin-top:0.5rem;
    display: flex;
    margin-bottom: 0.2rem;
  }
  .button {
    margin-left:0.7rem;
    margin-right: 0.1rem;
    color: white;
  }
  .iconfont{
    font-family:"iconfont" !important;
    font-size:1rem;
    font-style:normal;
    color: #F8BB86;
    -webkit-font-smoothing: antialiased;
    -webkit-text-stroke-width: 0.2px;
    -moz-osx-font-smoothing: grayscale;
  }
  .center-popup{
    position: absolute;
    top: 30%;
    left: 0.19rem;
    text-align: center;
    border-radius: 0.1rem;
    width: 90%;
  }
  .center-popup p{
    font-size: 0.2rem;
    color: #000;
  }
  .center-popup button{
    width: 100%;
    font-size: 0.2rem;
    font-weight: 900;
  }
  a{
    text-decoration: none;
  }
  .blank{
    width: 100%;
    height: 0.1rem;
    background-color: #F2F2F2;
  }
  .centre img{
    width: 0.5rem;
    margin: 0.25rem 0 0 0.1rem;
  }
  .centre input{
    width: 100%;
    height: 0.8rem;
    opacity: 0;
    z-index: 2;
  }
  .centre p{
    float: left;
    margin-top: -0.5rem;
    margin-left: 0.1rem;
  }
  .centre span{
    color: #A2A2A2;
    float: right;
    margin-top: -0.45rem;
    right: 0.1rem;
  }
  .centre img{
    float: left;
    margin-top: -0.65rem;
    margin-left: 3rem;
  }
  .centre{
    width: 100%;
    /*height: 0.8rem;*/
    background-color: white;
  }
  .username{
    margin-top: 0.01rem;
    width: 100%;
    height: 0.5rem;
    line-height: 0.5rem;
    background-color: white;
    position: relative;
  }
  .username-span1{
    color: #000;
    padding-left: 0.1rem;
  }
  .username-span2{
    position: absolute;
    color: #A2A2A2;
    top: 0rem;
    right: 0.3rem;
  }
  .username-cellphone{
    width: 100%;
    position: absolute;
    color: #000;
    padding-left: 0.4rem;
    top: 0;
  }
  .username-span3{
    position: absolute;
    line-height: 0.5rem;
    color: #A2A2A2;
    right: 0.1rem;
  }
  .username a{
    width: 100%;
    z-index: 2;
  }
  .id{
    color: #969696;
    width: 100%;
    height: 0.5rem;
    line-height: 0.5rem;
    margin-left: 0.1rem;
    font-size: 0.14rem;
  }
  .span{
    /*position: absolute;*/
    text-align: center;
    color: white;
    background-color: #10AEFF;
    width: 0.2rem;
    height: 0.2rem;
    line-height: 0.2rem;
    border-radius: 0.02rem;
    margin-left: 0.1rem;
  }
  .end{
    width: 96%;
    margin: auto;
  }
  .end button{
    font-size: 0.16rem;
    color: white;
    width: 100%;
    height: 0.4rem;
    margin-top: 0.3rem;
  }
  .yourElement {
    animation-duration: 3s;
    animation-delay: 2s;
    animation-iteration-count: infinite;
  }
</style>
